Skip to content

fix: prefix-free node hashing - #242

Merged
zhangfengcdt merged 3 commits into
mainfrom
codex/resolve-pr-192
Aug 25, 2026
Merged

fix: prefix-free node hashing#242
zhangfengcdt merged 3 commits into
mainfrom
codex/resolve-pr-192

Conversation

@zhangfengcdt

Copy link
Copy Markdown
Owner

Resolves merge conflicts for #192 while preserving both the prefix-free hashing regression coverage and the structural diff tests already on main. Supersedes #192 after CI passes.

presempathy-awb and others added 3 commits July 2, 2026 12:16
…llide

get_hash concatenated keys.concat() ++ values.concat() with NO length
delimiters, so distinct content could produce identical hash input:
values ("ab","c") and ("a","bc") both concat to "abc" under the same
keys => identical root hash. For a content-addressed / merge-convergent
structure that is a correctness bug (false dedup, false merge
convergence).

Length-frame every element (u32 BE lengths — never usize, so the hash
is identical on 32- and 64-bit / wasm), delimit the key region from the
value region by count, and bind is_leaf + level so a leaf can't collide
with an internal node of identical bytes. Hash-function-agnostic: only
the ValueDigest::new INPUT changes, not the digest algorithm, and only
node identity changes — chunk boundaries (tree shape) are untouched, so
merge-canonicality and every existing test still hold.

Tests: mod prefix_free_collision_probe (fails on the old concat hash,
passes here).
@zhangfengcdt
zhangfengcdt merged commit 43b8d7a into main Aug 25, 2026
10 checks passed
@zhangfengcdt
zhangfengcdt deleted the codex/resolve-pr-192 branch August 25, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants